import 'package:flutter/material.dart';
import 'package:flutter_shequ/page/home/homepage.dart';
import 'package:flutter_shequ/page/my/mypage.dart';

class TabsPage extends StatefulWidget {
  const TabsPage({super.key});

  @override
  // ignore: library_private_types_in_public_api
  _TabsPageState createState() => _TabsPageState();
}

class _TabsPageState extends State<TabsPage> {
  int currentIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('享+社区'),
        centerTitle: true,
      ),
      body: IndexedStack(
        index: currentIndex,
        children: const [
          Homepage(),
          Mypage(),
        ],
      ),
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        selectedItemColor: Colors.red,
        unselectedItemColor: Colors.black,
        items: [
          BottomNavigationBarItem(
              icon: Image.asset(
                'assets/tabs/home_active.png',
                width: 24,
                height: 24,
              ),
              label: '首页'),
          BottomNavigationBarItem(
              icon: Image.asset(
                'assets/tabs/my_active.png',
                width: 24,
                height: 24,
              ),
              label: '我的'),
        ],
        currentIndex: currentIndex,
        onTap: (int index) {
          setState(() {
            currentIndex = index;
          });
        },
      ),
    );
  }
}
